package com.campus.campusdelivery.constant;

public enum UserRole {
    STUDENT("STUDENT", "学生用户"),
    MERCHANT("MERCHANT", "商家用户"),
    DELIVERY("DELIVERY", "配送员"),
    ADMIN("ADMIN", "平台管理员");

    private final String code;
    private final String description;

    UserRole(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static UserRole fromCode(String code) {
        for (UserRole role : values()) {
            if (role.code.equals(code)) {
                return role;
            }
        }
        throw new IllegalArgumentException("Unknown role code: " + code);
    }
}
